using I2.Loc;
using UnityEngine;

public class MarketVehicleSkinButton : MarketButton
{
	public Product product;

	protected MarketProductsPanel parentProductsPanel;

	public UIPanel buttonPanel;

	public MarketPriceTag priceTag;

	public GameObject blockObject;

	public UILabel blockLabel;

	public UISprite checkSprite;

	public Color checkSpriteNormalColor;

	public Color checkSpriteDisabledColor;

	public Color selectedColor;

	public Color purchasedColor;

	public Color equippedColor;

	public Color normalColor;

	public UISprite boughtBackground;

	public float selectedScale = 1.02f;

	private bool availableTier = true;

	public override void OnClick()
	{
		base.OnClick();
		if ((bool)MarketPreviewController.upgradePreviewer)
		{
			MarketPreviewController.upgradePreviewer.ShowSkin(Resources.Load<Texture>("AllCarSkins/" + (product as ProductVehicleSkin).skinTextureName));
		}
		MarketControllerUI.instance.productsPanel.Select(id);
	}

	public void InitProductButton(MarketProductsPanel parentPanel, Product product)
	{
		this.product = product;
		parentProductsPanel = parentPanel;
		this.product.ApplySale();
		base.Init(product.id, parentPanel);
		LoadProductTexture(product);
		availableTier = CupsManager.CurrentTier >= product.tier;
		League leagueForIndex = CupsManager.GetLeagueForIndex(product.tier - 1);
		if (!product.Purchased)
		{
			if (!availableTier)
			{
				blockLabel.text = string.Format(ScriptLocalization.Get("Market/itemLeagueRequired"), ScriptLocalization.Get("Game_Common/" + leagueForIndex));
			}
			blockObject.SetActive(!availableTier);
		}
		else
		{
			blockObject.SetActive(false);
		}
		if (string.IsNullOrEmpty(parentPanel.selected) && product.Equipped)
		{
			Select(true);
		}
	}

	public void ResetProductButtonInfo(bool resetUpgrades)
	{
		SetProductButtonInfo(parentPanel.selected.Equals(product.id));
	}

	public void SetBought(bool bought)
	{
		boughtBackground.gameObject.SetActive(bought);
	}

	public override void Select(bool selected)
	{
		if (selected)
		{
			if ((bool)parentPanel.selectedButton)
			{
				parentPanel.selectedButton.Select(false);
			}
			parentPanel.selected = product.id;
			parentPanel.selectedButton = this;
			parentProductsPanel.selectedProductButton = null;
			parentProductsPanel.selectedProduct = product;
			MarketControllerUI.instance.previewController.ShowPreview();
			parentProductsPanel.productMiniInfoPanel.ShowMiniInfoPanel();
		}
		SetProductButtonInfo(selected);
	}

	private void SetProductButtonInfo(bool selected)
	{
		if (selected)
		{
			if (product is ProductComsumable)
			{
				parentProductsPanel.productMiniInfoPanel.ShowMiniInfoPanel();
			}
			MarketControllerUI.instance.mainButtons.SetMainButtons();
			selectedBG.alpha = 1f;
			base.transform.localScale = Vector3.one * selectedScale;
			buttonPanel.depth = 165;
		}
		else
		{
			selectedBG.alpha = 0f;
			base.transform.localScale = Vector3.one;
			buttonPanel.depth = 160;
		}
		SetStateAndTags(selected);
	}

	private void SetStateAndTags(bool selected)
	{
	}
}
